"use strict";
cc._RF.push(module, '06a81BhEy9Ev5lmLQLueIaF', 'View.BallShadowLayer');
// Script/2.Home/View.BallShadowLayer.ts

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const View_BallShadow_1 = require("./View.BallShadow");
const HoomEventCenter_1 = require("./HoomEventCenter");
const Model_RoomEvent_1 = require("./Model.RoomEvent");
const { ccclass, property } = cc._decorator;
let BallShadowManager = class BallShadowManager extends cc.Component {
    constructor() {
        super(...arguments);
        this.shadowNodePool = new cc.NodePool(View_BallShadow_1.default);
    }
    onLoad() {
        HoomEventCenter_1.HoomEventCenter.on(Model_RoomEvent_1.EventType.createBallShadow, this.onCreateShadow, this);
        HoomEventCenter_1.HoomEventCenter.on(Model_RoomEvent_1.EventType.recycleBallShadow, this.onRecycleShadow, this);
        this.shadowNode = this.node.find("shadow");
        this.shadowNodePool = new cc.NodePool(View_BallShadow_1.default);
    }
    onRecycleShadow(node) {
        this.shadowNodePool.put(node);
    }
    onCreateShadow(position, colorType) {
        let node;
        if (this.shadowNodePool.size() > 0) {
            node = this.shadowNodePool.get(View_BallShadow_1.default);
        }
        else {
            node = cc.instantiate(this.shadowNode);
        }
        node.getComponent(View_BallShadow_1.default).init(position, colorType);
        node.active = true;
        node.setParent(this.node);
    }
};
BallShadowManager = __decorate([
    ccclass
], BallShadowManager);
exports.default = BallShadowManager;

cc._RF.pop();